using ExampleMvcApplication.Controllers;
using ExampleMvcApplication.Models.Request;

namespace ExampleMvcApplication.Views.Account
{
    public class LogOn : Master<LogOnRequest>
    {
        protected override string RenderTitleContent()
        {
            return "Log On";
        }

        protected override string RenderMainContent(LogOnRequest model)
        {
            return Children._(
                h2._("Log On"),
                p._(
                    "Please enter your username and password. ",
                    a.href(UrlResolver.UrlFor<AccountController>(x => x.Register(model.ReturnUrl)))._("Register"),
                    " if you don't have an account. "
                    ),
                RenderErrorSummary(),
                form.action(UrlResolver.UrlFor<AccountController>(x => x.LogOn(default(LogOnRequest)))).method("post")._(
                    input.type("hidden").name("returnUrl").value(model.ReturnUrl),
                    div._(
                        fieldset._(
                            legend._("Account Information"),
                            p._(
                                label._for("username")._("Username:"),
                                input.type("text").name("username").value(model.UserName),
                                RenderError("username")
                                ),
                            p._(
                                label._for("password")._("Password:"),
                                input.type("password").name("password"),
                                RenderError("password")
                                ),
                            p._(
                                input.type("checkbox").name("rememberMe").value(model.RememberMe.ToString()),
                                label._for("password")._class("inline")._("Remember me?")
                                ),
                            p._(
                                input.type("submit").value("Log On")
                                )
                            )
                        )
                    )
                );
        }
    }
}